package com.longchat.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.longchat.dto.comm.ResultInfo;
import com.longchat.service.inter.award.IQuestionnaireService;

@Controller
@RequestMapping("/question")
public class VoteController {
	private String openid = "13xxxxxxxxxx";
	@Autowired
	private IQuestionnaireService questionnnaireService;
	
	@RequestMapping("")
	public ModelAndView question(Integer id){
		ModelAndView modelAndView = new ModelAndView("/question");
		/*modelAndView.addObject("question",questionnnaireService.findById(id));*/
		modelAndView.addObject("id",id);
		return modelAndView;
	}
	@RequestMapping("/findById")
	public ModelAndView findQuestionnaire(Integer id){
		ModelAndView modelAndView = new ModelAndView("/options");
		modelAndView.addObject("question",questionnnaireService.findById(id));
		return modelAndView;
	}
	@ResponseBody
	@RequestMapping("/vote")
	public ResultInfo vote(Integer questionnaireid,Integer optionid){
		return questionnnaireService.vote(openid,questionnaireid,optionid);
	}
	
}
